#include "flash_blob.h"

static uint32_t m7_flash_code[] = {
    0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2,
    0x4770BA40, 0x4770BAC0, 0x0030EA4F, 0x00004770, 0x48D34601, 0x68004448, 0x7080F100, 0xD9014288,
    0x47702001, 0xE7FC2000, 0x4603B578, 0x466E460C, 0x0003F003, 0xF004B910, 0xB1080003, 0xBD782001,
    0xE00C2100, 0x90005858, 0xE0052500, 0x42905C70, 0x2001D001, 0x1C6DE7F3, 0xD3F72D04, 0x42A11D09,
    0x2000D3F0, 0xB510E7EB, 0x48BE4603, 0xF3C06940, 0x4CBB6003, 0x6020444C, 0x68004620, 0xD0022801,
    0xD10C2803, 0xF44FE005, 0x4CB51080, 0x6020444C, 0xF44FE00B, 0x4CB21000, 0x6020444C, 0xF44FE005,
    0x4CAF0080, 0x6020444C, 0xBF00BF00, 0x4CAD48AE, 0x48AE6020, 0x48AE60A0, 0x462060A0, 0xF0406840,
    0x60600040, 0x680048AB, 0x4080F020, 0x0190F8C4, 0xF3EFBF00, 0x4CA88010, 0x6020444C, 0x2000B672,
    0x4601BD10, 0x6840489F, 0x0040F020, 0x60504A9D, 0x680048A0, 0x4080F040, 0x0190F8C2, 0x6010489F,
    0x68404610, 0x0020F040, 0x489B6050, 0x68004448, 0xB662B900, 0x47702000, 0x49962000, 0x60083920,
    0x48902100, 0x1174F8C0, 0x1178F8C0, 0x117CF8C0, 0xF0406840, 0x498B0004, 0xBF006048, 0x69404889,
    0x0004F000, 0xD0F92800, 0xBF00BF00, 0x69404885, 0x0004F040, 0x61484983, 0x30FFF04F, 0x39204985,
    0x46016008, 0xF8C0487F, 0xF8C01174, 0xF8C01178, 0x2000117C, 0xB5104770, 0x21004602, 0x7080F1A2,
    0x487C0B01, 0x0A0B3820, 0x0023F850, 0x04C4F3C1, 0x40A32301, 0x0303EA20, 0x38204876, 0xF8400A0C,
    0x48703024, 0x4B766840, 0x4B6E4018, 0x03086058, 0x46186058, 0xF0406840, 0x60580002, 0x68404618,
    0x0010F040, 0xBF006058, 0xBF00BF00, 0x8F4FF3BF, 0xBF00BF00, 0xBF00BF00, 0x69404862, 0x0002F000,
    0xD0F92800, 0x6940485F, 0x0002F040, 0x61584B5D, 0x38204860, 0xF8500A0B, 0xF3C10023, 0x230104C4,
    0x431840A3, 0x3B204B5B, 0xF8430A0C, 0x20000024, 0xBF00BD10, 0xBF00BF00, 0x8F4FF3BF, 0xBF00BF00,
    0x4850BF00, 0xF0406840, 0x494E0008, 0xBF006048, 0x6940484C, 0x0001F000, 0xD0F92800, 0xBF00BF00,
    0xE92D4770, 0x46054DF0, 0x4690460E, 0x0B96EA4F, 0x0007F005, 0xF1B8B930, 0xD0030F00, 0x0007F006,
    0xB916B900, 0xE8BD2001, 0xF1A58DF0, 0x0B2C7580, 0x4840E00F, 0x0A213820, 0x0021F850, 0x02C4F3C4,
    0x40912101, 0x493B4388, 0x0A223920, 0x0022F841, 0x19A83408, 0xEBB41E40, 0xD9EA3F10, 0x68404831,
    0x0001F040, 0x6048492F, 0xBF00BF00, 0xF3BFBF00, 0xBF008F4F, 0xBF00BF00, 0x46C2462F, 0xE0112400,
    0x7080F04F, 0x1000F8DA, 0xF00751C1, 0x281C001F, 0x1C60D002, 0xD3014558, 0xFF9BF7FF, 0xF10A1C64,
    0x1D3F0A04, 0xD3EB455C, 0x6940481E, 0x0001F040, 0x6148491C, 0x68404608, 0x0001F020, 0x0B2C6048,
    0x481CE00F, 0x0A213820, 0x1021F850, 0x02C4F3C4, 0x40902001, 0x48174301, 0x0A223820, 0x1022F840,
    0x19A83408, 0xEBB41E40, 0xD9EA3F10, 0xE79A2000, 0x4603B510, 0x0003F003, 0xF001B910, 0xB1080003,
    0xBD102001, 0x6818E008, 0x42A06814, 0x4618D001, 0x1D1BE7F7, 0x1F091D12, 0xD1F42900, 0xE7F02000,
    0x00000004, 0x40192000, 0x54544139, 0x45670123, 0xCDEF89AB, 0x40192190, 0x00000008, 0xB29685B2,
    0xFFC00FFF, 0x00000000, 0x00000000, 0x00000000
};

program_target_t m7_flash_algo = {
    0x20100087,         // Init
    0x20100103,         // UnInit
    0x20100139,         // EraseChip
    0x20100197,         // EraseSector
    0x20100263,         // ProgramPage
    0x20100049,         // CheckBlank
    0x20100351,         // Verify

    // BKPT : start of blob + 1
    // RSB  : address to access global/static data
    // RSP  : stack pointer
    {
        0,
        0,
        0
    },

    M7_RAM_ADDRESS_BASE + RESERVE_ALGO_SIZE,   	// mem buffer location
    M7_RAM_ADDRESS_BASE,         				// location to write prog_blob in target RAM
    sizeof(m7_flash_code), 						// prog_blob size
    m7_flash_code,         						// address of prog_blob
    RAM_DATA_SIZE,         						// ram_to_flash_bytes_to_be_written
};

static uint32_t m0_flash_code[] = {
    0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2,
    0x4770BA40, 0x4770BAC0, 0x4603B578, 0x466E430B, 0xD106079B, 0x58C4E00B, 0x5CF59400, 0x42952400,
    0x2001D001, 0x1C64BD78, 0xD3F82C04, 0x428B1D1B, 0x2000D3F1, 0x487BBD78, 0x60014979, 0x6081497A,
    0x6081497A, 0x22406841, 0x60414311, 0x8010F3EF, 0x44494977, 0xB6726008, 0x47702000, 0x68414871,
    0x43912240, 0x496E6041, 0x600143C9, 0x22206841, 0x60414311, 0x4448486E, 0x28006800, 0xB662D100,
    0x47702000, 0x20004A67, 0x60103240, 0x60906050, 0x486460D0, 0x23046841, 0x60414319, 0x07496941,
    0x6941D5FC, 0x61414319, 0x43C02000, 0x60506010, 0x60D06090, 0x47702000, 0x0C41B570, 0x014A03C0,
    0x48580EC6, 0x00891993, 0x6C0C1809, 0x462A2501, 0x439440B2, 0x6844640C, 0x0336267F, 0x604443B4,
    0x031B6844, 0x431C1C9B, 0x68436044, 0x43232410, 0xF3BF6043, 0x69438F4F, 0xD5FC079B, 0x24026943,
    0x61434323, 0x43106C08, 0x484A6408, 0x07C96801, 0x6801D009, 0x00490849, 0x68416001, 0xD1FC0789,
    0x43296801, 0x20006001, 0xB5F0BD70, 0x088B4606, 0x07404696, 0x0010D10A, 0x0748D008, 0x2900D106,
    0x0B30D004, 0x46841871, 0xE00D0B0C, 0xBDF02001, 0x008A0941, 0x18514933, 0x06C26C0F, 0x25010ED2,
    0x43AF4095, 0x1C40640F, 0xD2F14284, 0x68684D2D, 0x43082101, 0xF3BF6068, 0x21008F4F, 0x46724630,
    0xE0132708, 0x60066816, 0x0EF606C6, 0xD0022E1C, 0x429E1C4E, 0xF3BFD307, 0x686E8F4F, 0x606E433E,
    0x07F6696E, 0x1D00D0FC, 0x1D121C49, 0xD3E94299, 0x22016968, 0x61684310, 0x43906868, 0x46606068,
    0x0941E00A, 0x19490089, 0x06C66C0B, 0x46170EF6, 0x433B40B7, 0x1C40640B, 0xD2F24284, 0x68014815,
    0xD00907C9, 0x08496801, 0x60010049, 0x07896841, 0x6801D1FC, 0x60014311, 0xBDF02000, 0xB5104603,
    0x079B430B, 0x2001D008, 0x6803BD10, 0x42A36814, 0x1D00D1FA, 0x1D121F09, 0xD1F62900, 0xBD102000,
    0x4D697A4D, 0x40010000, 0x45670123, 0xCDEF89AB, 0x00000004, 0x40005000, 0x00000000, 0x00000000
};

program_target_t m0_flash_algo = {
    0x30000057,         // Init
    0x3000007D,         // UnInit
    0x300000A5,         // EraseChip
    0x300000D9,         // EraseSector
    0x3000014B,         // ProgramPage
    0x30000029,         // CheckBlank
    0x3000021D,         // Verify

    // BKPT : start of blob + 1
    // RSB  : address to access global/static data
    // RSP  : stack pointer
    {
        0,
        0,
        0
    },

    M0_RAM_ADDRESS_BASE + RESERVE_ALGO_SIZE,   	// mem buffer location
    M0_RAM_ADDRESS_BASE,         				// location to write prog_blob in target RAM
    sizeof(m0_flash_code), 						// prog_blob size
    m0_flash_code,         						// address of prog_blob
    RAM_DATA_SIZE,         						// ram_to_flash_bytes_to_be_written
};


